<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => {
    assert_not_equals(window.eventSender, undefined,
        'This test requires eventSender');

    assert_selection(
        '<div contenteditable><span id="dragme">^hello|</span> world</div>',
        selection => {
            // Drag 'hello'
            const dragMe = selection.document.getElementById('dragme');
            const editor = dragMe.parentNode;
            const editorLeft = editor.offsetLeft + selection.document.offsetLeft;
            const editorTop = editor.offsetTop + selection.document.offsetTop;
            const x = editorLeft + dragMe.offsetWidth / 2;
            const y = editorTop + dragMe.offsetHeight / 2;
            eventSender.mouseMoveTo(x, y);
            eventSender.mouseDown();
            // and drop it off to the right somewhere
            eventSender.leapForward(500);
            eventSender.mouseMoveTo(editorLeft + editor.offsetWidth, y);
            eventSender.mouseUp();
        },
        '<div contenteditable>world^hello|</div>',
        'Drag "hello" after "wold"');
});
</script>
